<style scoped>
.container {
  padding: 20px;
  background-color: #999;
  width: 400px;
  margin: 100px auto;
}
.title {
  display: flex;
  justify-content: space-around;
}

.title span {
  width: 80px;
  height: 40px;
  background-color: #ccc;
  color: #000;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.title span.active {
  background-color: skyblue;
}

.content {
  background-color: skyblue;
  height: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
}
</style>

<template>
  <div class="container">
    <div class="title">
      <span
        v-for="(v, i) in list"
        :key="i"
        :class="i === activeIndex ? 'active' : ''"
        @click="activeIndex = i"
        >{{ v.ttile }}</span
      >
    </div>
    <div class="content">{{ list[activeIndex].con }}</div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
  name: "",
  props: {},
  components: {},
  data() {
    return {
      list: [
        {
          ttile: "标题一",
          con: "内容一",
        },
        {
          ttile: "标题二",
          con: "内容二",
        },
        {
          ttile: "标题三",
          con: "内容三",
        },
        {
          ttile: "标题四",
          con: "内容四",
        },
      ],
      activeIndex: 0,
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
});
</script>
